﻿using System;
using enyo;

namespace com.RexToy
{
    public class UnitConverter : enyo.Control
    {
        private new object[] Components = new enyo.Object[]{
            new RadioGroup() { Kind = ControlKind.RadioGroup,
                Components = new Control[]{
                    new RadioButton() {Kind = ControlKind.RadioButton, Name = "temp", Caption = enyo.g11nGlobal._L("Temperature"), Value = 0, onclick ="selectView"},
                    new RadioButton() {Kind = ControlKind.RadioButton, Name = "leng", Caption = enyo.g11nGlobal._L("Length"), Value = 1, onclick ="selectView"},
                    new RadioButton() {Kind = ControlKind.RadioButton, Name = "wght", Caption = enyo.g11nGlobal._L("Weight"), Value = 2, onclick ="selectView"},
                    new RadioButton() {Kind = ControlKind.RadioButton, Name = "area", Caption = enyo.g11nGlobal._L("Area"), Value = 3, onclick ="selectView"},
                    new RadioButton() {Kind = ControlKind.RadioButton, Name = "volm", Caption = enyo.g11nGlobal._L("Volume"), Value = 4, onclick ="selectView"},
                    new RadioButton() {Kind = ControlKind.RadioButton, Name = "engy", Caption = enyo.g11nGlobal._L("Energy"), Value = 5, onclick ="selectView"},
                    new RadioButton() {Kind = ControlKind.RadioButton, Name = "angl", Caption = enyo.g11nGlobal._L("Angle"), Value = 6, onclick ="selectView"},
                    new RadioButton() {Kind = ControlKind.RadioButton, Name = "pres", Caption = enyo.g11nGlobal._L("Pressure"), Value = 7, onclick ="selectView"}                    
                }
            },

            new Pane(){Kind = ControlKind.Pane, TransitionKind = Transitions.LeftRightFlyin,
                Components = new Control[]{
                    new Control() {Kind= "com.RexToy.TempView"},
				    new Control() {Kind= "com.RexToy.LengView"},
				    new Control() {Kind= "com.RexToy.WghtView"},
				    new Control() {Kind= "com.RexToy.AreaView"},
				    new Control() {Kind= "com.RexToy.VolmView"},
				    new Control() {Kind= "com.RexToy.EngyView"},
				    new Control() {Kind= "com.RexToy.AnglView"},
				    new Control() {Kind= "com.RexToy.PresView"}
                }
            }
        };

        public override void Create()
        {
            this.Inherited(Arguments.Value);

            enyo.g11nGlobal._L("");
        }

        public void SelectView(Control sender, object evt)
        {
            var pane = this._["pane"] as Pane;
            pane.SelectViewByIndex((int)sender["value"], false);
        }
    }
}
